package com.example.java_chatroom.controller;

import com.example.java_chatroom.model.Message;
import com.example.java_chatroom.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

@RestController
public class MessageController {
    @Autowired
    private MessageService messageService;

    @RequestMapping("/message")
    public List<Message> getMessage(Integer sessionId){
        List<Message> messages=messageService.getMessage(sessionId);
        //针对查询结果进行逆置
        Collections.reverse(messages);
        return messages;
    }
}
